package cn.mcch.investigator.fragment;

import android.util.SparseArray;

/**
 * Created by Administrator on 2016/12/17.
 */
public class FragmentFactory {

    private static SparseArray<BaseFragment> array = new SparseArray<BaseFragment>();

    public static BaseFragment getFragmentFromPosition(int position) {
        BaseFragment baseFragment = array.get(position);
        if (baseFragment == null) {
            switch (position) {
                case 0:
                    // 创建任务
                    baseFragment = new CreateTaskFragment();
                    break;
                case 1:
                    // 我的任务
                    baseFragment = new MyTaskFragment();
                    break;
                case 2:
                    // 综合查询
                    baseFragment = new FindFragment();
                    break;
                case 3:
                    // 修改密码
                    baseFragment = new UpdatePasswordFragment();
                    break;
                default:
                    break;
            }
            array.put(position, baseFragment);
        }
        return baseFragment;
    }

    public static void clear() {
        array.clear();
    }
}
